package com.szcinda.controller;


import com.szcinda.controller.configuration.UserLoginToken;
import com.szcinda.repository.Notes;
import com.szcinda.service.dto.notes.NotesService;
import com.szcinda.service.dto.notes.NotesCreateDto;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("notes")
public class NotesController {

    private final NotesService notesService;

    public NotesController(NotesService notesService) {
        this.notesService = notesService;
    }

    @UserLoginToken
    @PostMapping("create")
    @OperationLogAnnotation(operDesc = "创建备忘录", operModel = "备忘录")
    public Result<String> create(@RequestBody NotesCreateDto createDto) {
        notesService.create(createDto);
        return Result.success();
    }

    @UserLoginToken
    @GetMapping("fix/{id}")
    @OperationLogAnnotation(operDesc = "修改备忘录", operModel = "备忘录")
    public Result<String> fix(@PathVariable String id) {
        notesService.fix(id);
        return Result.success();
    }
    @UserLoginToken
    @GetMapping("del/{id}")
    @OperationLogAnnotation(operDesc = "删除备忘录", operModel = "备忘录")
    public Result<String> del(@PathVariable String id) {
        notesService.del(id);
        return Result.success();
    }

    @GetMapping("getMyNotes/{userId}/{orgId}")
    public Result<List<Notes>> getMyNotes(@PathVariable String userId, @PathVariable String orgId) {
        return Result.success(notesService.getAll(userId, orgId));
    }
}
